﻿package view.components 
{
	import flash.text.AntiAliasType;
	import flash.text.GridFitType;
	
	/**
	 * ...
	 * @author Slavshik Alexander
	 */
	public class TabMenuItem extends TabMenuItemTemplate
	{
		private var _selected:Boolean = false;
		private static var _lastSelected:TabMenuItem;
		private var _text:String;
		
		public function TabMenuItem() {
			hit_mc.buttonMode = true;
			selected_txt.autoSize = unselected_txt.autoSize = "left";
			unselected_txt.gridFitType = selected_txt.gridFitType = GridFitType.PIXEL;
			unselected_txt.antiAliasType = selected_txt.antiAliasType = AntiAliasType.ADVANCED;
			unselected_txt.visible = true;
			selected_txt.visible = false;
		}
		
		public function get selected():Boolean { 
			return _selected;
		}
		public function set selected(value:Boolean):void {
			if (_selected == value) return;
			if (_lastSelected != null) _lastSelected.selected = !value;
			if (value) _lastSelected = this;
			_selected = value;
			hit_mc.mouseEnabled = !_selected;
			unselected_txt.visible = !value;
			selected_txt.visible = value;
		}
		
		public function get text():String { 
			return _text;
		}
		public function set text(value:String):void {
			_text = value;
			unselected_txt.text = selected_txt.text = value;
			hit_mc.width = selected_txt.width + selected_txt.x * 2;
		}
		
	}
	
}